package org.utils;

public class ExceptionEx {
    // 错误堆栈的内容
    public static String e2s(Exception e) {
        StringBuilder sb = new StringBuilder();
        sb.append(e);
        sb.append("\n");
        for (StackTraceElement ste : e.getStackTrace()) {
            sb.append("at ");
            sb.append(ste);
            sb.append("\n");
        }
        return sb.toString();
    }

    // 错误堆栈的内容
    public static String t2s(Throwable t) {
        StringBuilder sb = new StringBuilder();
        sb.append(t);
        sb.append("\n");
        for (StackTraceElement ste : t.getStackTrace()) {
            sb.append("at ");
            sb.append(ste);
            sb.append("\n");
        }
        return sb.toString();
    }
}
